package org.sql.statement.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.sql.statement.builder.Constants;

public class StatementUtil implements Constants {

	public static String getAllButLast(final StringBuilder sb, int length) {
		if (sb.length() < length)
			return sb.toString();

		return sb.substring(0, sb.length() - length);
	}

	public static void throwException(String... args) {
		final StringBuilder sb = new StringBuilder();

		for (String string : args)
			sb.append(string).append(STR_COMMA_SPACE);

		throw new RuntimeException(getAllButLast(sb, 2));
	}

	public static List<String> getMapKeys(final Map<String, Object> map) {
		final List<String> list = new ArrayList<String>();

		for (String string : map.keySet())
			list.add(string);

		return list;
	}

	public static List<Object> getMapValues(final Map<String, Object> map) {
		final List<Object> list = new ArrayList<Object>();

		for (Object obj : map.values())
			list.add(obj);

		return list;
	}

}
